package com.hj.pet.model;

import com.hj.pet.constant.Code;
import lombok.Data;

import java.io.Serializable;

import static com.hj.pet.model.Constant.*;

@Data
public class ReturnT<T> implements Serializable {
    public static final long serialVersionUID=208L;
    public static ReturnT<String> errorReturn = new ReturnT<>(Code.FAIL, "发生服务器错误，请重试");

    private int code;
    private String msg;
    private T data;
    public ReturnT(){}
    public ReturnT(int code){
        this.code = code;
    }

    public ReturnT(int code, T data) {
        this.code = code;
        this.data = data;
    }
    public ReturnT(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public ReturnT<T> setReturn(int code, String msg){
        this.code = code;
        this.msg = msg;
        return this;
    }

    public ReturnT<T> setReturn(int code, String msg,T data){
        this.code = code;
        this.msg = msg;
        this.data = data;
        return this;
    }
    @Override
    public String toString() {
        return "ReturnT[" +
                "code=" + code +
                ", msg='" + msg +
                ", data=" + data +
                ']';
    }
}